package com.example.ObserverPattern_EventBus.config;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;

/**
 * <pre>
 * 功能描述：
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/12/12 21:56
 */
@Configuration
public class EventBusConfig {

    @Bean
    public EventBus eventBus() {
        return new EventBus(); //同步阻塞模式
    }

    @Bean
    public EventBus asyncEventBus() {
        return new AsyncEventBus(Executors.newFixedThreadPool(10));//异步非阻塞模式
    }
}
